import { ReactElement } from "react";
import style from "./List.module.css";

type ListProps = {
  title: string;
  data: any[];
  renderItem: (item: any, index: number) => ReactElement;
};

export default function List(props: ListProps) {
  const { title, data, renderItem } = props;
  return (
    <div className={style.list}>
      <div className={style.title}>{title}</div>
      <ul>
        {data.map((item, index) => (
          <li key={index} className={style.listItem}>
            {renderItem(item, index)}
          </li>
        ))}
      </ul>
    </div>
  );
}
